package com.jack.cms.oss.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import com.jack.cms.oss.core.QiniuImageUtils;
import com.jack.cms.oss.core.QiniuUtils;
import com.jack.cms.oss.service.ImageService;

@Service
public class ImageServiceImpl extends OssServiceImpl implements ImageService {

	@Resource
	private QiniuImageUtils qiniuImageUtils;

	@Override
	public String save(MultipartFile fileUpLoad) throws Exception {
		if (!QiniuImageUtils.checkImageSuffix(fileUpLoad.getOriginalFilename())) {
			throw new RuntimeException("系统只支持.jpg,.jpeg,.gif,.png,.bmp格式的图片，请重新上传");
		}
		return super.save(fileUpLoad);
	}

	@Override
	protected QiniuUtils getQiniuUtil() {
		return qiniuImageUtils;
	}
}
